package com.chao.config;

import com.chao.interceptor.AuthorityInterceptor;
import com.chao.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

// 设置为 配置类 加载到容器中
@Configuration
public class SpringMVCConfig implements WebMvcConfigurer {

    // 能过通过过滤器的 地址
    private final static String[] URL = {"/regist.html", "/regist", "/main", "/login", "/js/**", "/css/**", "/images/**", "/fonts/**"};
    // 通过权限检查的 地址
    private final static String[] Authority_URL = {"/regist.html", "/regist", "/main", "/login", "/js/**", "/css/**", "/images/**", "/fonts/**"};
/// /deleteTeacher  deleteCourse course_arrange_delete_all sysMsgDelete
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //登录拦截
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(URL);

        // 权限检查
        registry.addInterceptor(new AuthorityInterceptor())
                .addPathPatterns("/**")
                .excludePathPatterns(URL);
    }


}
